<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns="http://www.w3.org/1999/xhtml"
                template="./base.template.xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:t="http://myfaces.apache.org/tomahawk">

    <ui:define name="top">
    </ui:define>
    <ui:define name="page_title">   
        CATALOGO DE DEPARTAMENTOS
        <h:form id="_frmSearchDepartments">
            <div align="center">
                <h:panelGrid columns="4" cellpadding="5" width="70%" style="border-style: solid; border-width: thin; border-color: lightgray; margin-bottom: 1em;">
                    <h:outputLabel for="_departmentId" value="Codigo:" style="font-weight:bold"/>
                    <p:inputText id="_departmentId" value="#{departmentBean.departmentId}" />
                    <h:outputLabel for="_departmentName" value="Nombre:" style="font-weight:bold"/>
                    <p:inputText id="_departmentName" value="#{departmentBean.departmentName}" />
                </h:panelGrid>
                <p:commandButton value="BUSCAR" update=":_frmResultDeparments:_tblDepartments"  
                                 action="#{departmentBean.findDepartments}" /> 
                <p:commandButton value="LIMPIAR" update=":_frmResultDeparments:_tblDepartments"  
                                 action="#{departmentBean.reset}" />
            </div>
        </h:form>
    </ui:define>
    <ui:define name="content">
        <h:form id="_frmResultDeparments">
            <p:dataTable id="_tblDepartments" var="vDep" value="#{departmentBean.departments}">
                <p:column headerText="Codigo">
                    <p:commandLink actionListener="#{departmentBean.editDepartment}">
                        <h:outputText value="Depto 1" />
                    </p:commandLink>
                </p:column>
                <p:column headerText="Nombre">
                    <h:outputText value="#{vDep.description}" />
                </p:column>
            </p:dataTable>
            <!-- ADD, MODIFY AND DELETE DEPARTMENT MODAL WINDOW -->
            <p:dialog id="_modDepartments" header="Editar Departamento" widgetVar="_modDep" modal="true">  
                <div align="center">
                    <h:panelGrid id="_panModDepartments" columns="4" cellpadding="5" width="70%" style="border-style: solid; border-width: thin; border-color: lightgray; margin-bottom: 1em;">
                        <h:outputLabel for="_modDepartmentId" value="Codigo:" style="font-weight:bold"/>
                        <p:inputText id="_modDepartmentId" value="#{departmentBean.departmentId}" />
                        <h:outputLabel for="_modDepartmentName" value="Nombre:" style="font-weight:bold"/>
                        <p:inputText id="_modDepartmentName" value="#{departmentBean.departmentName}" />
                    </h:panelGrid>
                    <p:commandButton value="SALVAR" update=":_frmResultDeparments:_tblDepartments"  
                                     action="#{departmentBean.findDepartments}" /> 
                    <p:commandButton value="ELIMINAR" update=":_frmResultDeparments:_tblDepartments, :_frmSearchDepartments"  
                                     action="#{departmentBean.reset}" />
                    <p:commandButton value="CANCELAR" update=":_frmResultDeparments:_tblDepartments, :_frmSearchDepartments"  
                                     action="#{departmentBean.reset}" />
                </div>
            </p:dialog>





            <p:outputLabel id="_lblTest" value="#{departmentBean.department}"/>
        </h:form>

        <h:form id="carForm">
            <p:carousel value="#{departmentBean.departments}" var="car" itemStyle="width:200px" >
                <p:column>
                    <p:commandLink update=":carForm:detail" oncomplete="dlg.show()">
                        <h:outputText value="Model: #{car.description}" />
                        <f:setPropertyActionListener value="#{car}" target="#{departmentBean.department}" />
                    </p:commandLink>
                </p:column>
            </p:carousel>
            <p:dialog widgetVar="dlg">
                <h:outputText id="detail" value="#{departmentBean.department}" />
            </p:dialog>
        </h:form>

    </ui:define>
    <ui:define name="bottom">
        bottom
    </ui:define>
</ui:composition>